package cn.demomaster.quicklogger.sample;

import android.app.Application;
import android.os.Environment;
import android.util.Log;

import java.io.File;

import cn.demomaster.quicklogger.QdLog;
import cn.demomaster.quicklogger.config.LogConfig;
import cn.demomaster.quicklogger.config.LogConfigBuilder;
import cn.demomaster.quicklogger.interceptor.LogInterceptor;
import cn.demomaster.quicklogger.model.LogInfo;

public class MyApp extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        LogConfig logConfig = new LogConfigBuilder(this)
                .setSaveExternalStorageBeforeAndroidQ(false)
                .setSaveExternalStoragePath(new File(Environment.getExternalStorageDirectory(),"qdlog/log"))
                .setLogLevel(Log.DEBUG)//打印级别 小于此级别的日志不写入到文件
                .build();
        QdLog.init(this,logConfig);
        QdLog.i("应用启动");
        QdLog.addInterceptor(new LogInterceptor() {
            @Override
            public void onLog(LogInfo logInfo) {
                //Log.e("QDLog", logInfo.getMsg().toString());
            }
        });
    }
}
